package com.micro.modual.controller;

import com.micro.core.resp.RespJson;
import com.micro.core.resp.RespJsonData;
import com.micro.core.resp.RespJsonPageData;
import com.micro.modual.model.bo.goodscomment.GoodsCommentBO;
import com.micro.modual.model.dto.goodscomment.GoodsCommentDetailDTO;
import com.micro.modual.model.dto.goodscomment.GoodsCommentListDTO;
import com.micro.modual.service.GoodsCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;

import java.util.Map;

/**
 * <h1>商品评论表 控制器</h1>
 * @author levelcoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:27:47
 */
@Api(value = "商品评论管理",tags = "商品评论管理")
@RestController
@RequestMapping(value = "goodsComment")
public class GoodsCommentController {

    @Autowired
    private GoodsCommentService goodsCommentService;

    /**
     * <h2>查找商品评论表 列表</h2>
     * @param params 列表查询请求对象
     * @return List<GoodsCommentListDTO> {@link GoodsCommentListDTO}s  商品评论表 列表返回对象
     */
    @ApiOperation(value = "查询商品评论表列表" ,notes = "查询商品评论表列表")
    @GetMapping(value = "/findGoodsCommentList")
    public RespJsonPageData<GoodsCommentListDTO> findGoodsCommentList(@RequestParam  Map<String,Object> params){
        return goodsCommentService.findList(params,GoodsCommentListDTO.class);
    }

    /**
     * <h2>根据主键编号查看商品评论表详情</h2>
     * @param id  商品评论表 主键编号
     * @return {@link GoodsCommentDetailDTO}  商品评论表 详情
     */
    @ApiOperation(value = "查询商品评论表详情",notes = "根据主键编号，查询商品评论表详情")
    @GetMapping(value = "/findGoodsCommentDetail/{id}")
    public RespJsonData<GoodsCommentDetailDTO> findGoodsCommentDetail(@PathVariable("id") Long id){
        return goodsCommentService.findDetail(id,GoodsCommentDetailDTO.class);
    }

    /**
     * <h2>新增商品评论表详情</h2>
     * @param goodsCommentBO {@link GoodsCommentBO} 商品评论表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "新增商品评论表",notes = "新增商品评论表")
    @PostMapping(value = "/addGoodsComment")
    public RespJson addGoodsComment(@RequestBody GoodsCommentBO goodsCommentBO){
        return goodsCommentService.addGoodsComment(goodsCommentBO);
    }

    /**
     * <h2>修改商品评论表详情</h2>
     * @param goodsCommentBO  {@link GoodsCommentBO} 商品评论表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "修改商品评论表",notes = "修改商品评论表")
    @PostMapping(value = "/editGoodsComment")
    public RespJson editGoodsComment(@RequestBody GoodsCommentBO goodsCommentBO){
        return goodsCommentService.editGoodsComment(goodsCommentBO);
    }

    /**
     * <h2>根据主键编号删除商品评论表信息</h2>
     * @param id  商品评论表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "删除商品评论表",notes = "根据地址ID，删除商品评论表")
    @PostMapping(value = "/deleteGoodsComment/{id}")
    public RespJson deleteGoodsComment(@PathVariable("id") Long id){
        return goodsCommentService.deleteGoodsComment(id);
    }
}

